﻿@model Domain.Entity.Game



<div id="titlelessItem">
    <div class = "item" style="padding-bottom: 40px;min-height: 214px;">

        <div  style="width: 63%;display:inline-block;">
                
                                    <div>
                <h2 class="title @Html.GetColor(Request.Cookies["color"])" style="height: 12px; font-size: 12px;" >Game Of The Week</h2>
                    </div><br/>
                <h1 class="title coolBlack">@Html.ActionLink(@Model.Name, "Game", "Game", new {id = @Model.Id, viewname ="GameWithLayout"}, null)</h1>
                <br/>
            <h3 class="descBox descBlack" style="width: 315px">
                @if(Model.Description.Split(' ').Count() > 70)
                {
                    for(int i = 0; i < 70; i++)
                    {
                        @(Model.Description.Split(' ').ElementAt(i) + " ")
                    }
                    @("...")
                }
                else
                {
                    @Model.Description
                }

            </h3><br/>
                <div class="sideBox @Html.GetColor(Request.Cookies["color"])" style="width: 295px;padding-bottom: 20px; font-weight: bold; margin-bottom: 5px;">
                    <div style="float:left;">Year Released</div>
                    <div style="float:right;">@Model.ReleaseDate.Month/@Model.ReleaseDate.Day/@Model.ReleaseDate.Year</div>
                </div>
                <div class="sideBox @Html.GetColor(Request.Cookies["color"])" style="width: 295px;padding-bottom: 20px; font-weight: bold; margin-bottom: 5px;">
                    <div style="float:left;">Rating</div>
                    <div style="float:right;">@string.Format("{0:0.0}",Model.AverageRating)/5</div>
                </div>

                @if (Model.MetaScores.Any())
                {
                    <div class="sideBox @Html.GetColor(Request.Cookies["color"])" style="width: 295px;padding-bottom: 20px; font-weight: bold; margin-bottom: 5px;">
                        <div style="float:left;">Meta Score</div>
                        <div style="float:right;">@Model.MetaScores.Select(s => s.Score).Average()</div>
                    </div>
                }
                   
                <div class="sideBox @Html.GetColor(Request.Cookies["color"])" style="padding: 15px; width: 63%;">
                    
                    @if(User.Identity.Name != "")
                    {
                        @Html.ActionLink("Create Review", "CreateReview", "Review", new { gameId = Model.Id }, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
                    }

                    @if (Model.Articles.Any())
                    {
                        @Html.ActionLink("News", "ViewGameNews", "News", new { gameId = Model.Id }, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
                    }
            
                    @if (Model.SystemRequirements != null)
                    {
                        <br /><br/>@Html.ActionLink("System Requirements", "ViewRequirements", "Game", new { gameId = Model.Id }, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
                    }
                </div>  
            </div>

            @* I wish there was a better way :( *@
            @if (@Model.Pictures.FirstOrDefault() != null)
            {
                <a class="itemDisplayImage"   style="background-color: white ! important; background-image: url(@Url.Action("GetDisplayImage", "Game",
                  new { Model.Id, index=0 })), none ! important; background-repeat: no-repeat, repeat ! important; background-attachment: scroll, scroll ! important; background-position: center center, 0% 0% ! 
                      important; background-clip: border-box, border-box ! important; background-origin: padding-box, padding-box ! important; width: 175px; height: 200px; background-size: 100% 100%; top: 20px;" 
                   href="@Url.Action("Game", "Game", new { id = @Model.Id, viewname = "GameWithLayout" }, null)">
                </a>
            }
            else
            {
                <a class="itemDisplayImage"   style="background-color: white ! important; background-image: url('../../GamersParadise/Images/NoImage.png'), none ! important; background-repeat: no-repeat, repeat ! important; background-attachment: scroll, scroll ! important; background-position: center center, 0% 0% ! 
                  important; background-clip: border-box, border-box ! important; background-origin: padding-box, padding-box ! important; width: 175px; height: 200px; background-size: 100% 100%; top: 20px;" 
                   href="@Url.Action("Game", "Game", new { id = @Model.Id, viewname = "GameWithLayout" }, null)"></a>
                    
            } 

        </div>

    </div>